{% extends "./inc/base.html" %}
{% block content %}
<section class="vbox">
    <header class="header bg-light dk">
        <ul class="nav nav-tabs pull-left">
            <li class="active"><a data-toggle="tab" href="#"><i class="fa fa-comments text-muted"></i> 话题管理 </a></li>
            </li>
        </ul>
    </header>

    <section class="scrollable wrapper">

        <section class="panel panel-default">
            <header class="panel-heading clearfix">
                <ul class="nav nav-tabs pull-left">
                    <li class="{{controller.get('type')|default('active', true)}}"><a  href="/admin/keyword/index"> 话题列表 </a></li>
                    <li class="{%if controller.get('type')=='parent'%}active{%endif%}"><a  href="/admin/keyword/index/?type=parent">根话题</a>
                    <li ><a class="todo"  href="/admin/keyword/search">搜索</a>
                    <li ><a class="todo" href="/admin/keyword/today">今日话题</a>
                    </li>
                </ul>
                <i title="" data-original-title="" class="fa fa-info-sign text-muted pull-right"  data-toggle="tooltip" data-placement="bottom" data-title=""><i class="fa fa-question-circle"></i></i>
            </header>
            <div class="row wrapper">
                <div class="col-sm-9 m-b-xs">
                    <a href="/admin/keyword/add" class="btn  btn-info" >新建话题</a>
                    <a class="btn btn-info ajax-post confirm" target-form="ids" href="/admin/keyword/del">删除话题</a>
                    <a class="btn  btn-info ajax-post" target-form="ids" href="/admin/keyword/lock/?lock=1" >锁定话题</a>

                </div>
                <div class="col-sm-3">
                    <div class="input-group pull-right search-form">
                        <input type="text" class="input-sm form-control" name="keyname" placeholder="请输入关键字"
                               value="{{controller.get('keyname')}}">
                        <span class="input-group-btn">
                        <button class="btn btn-sm btn-default" type="button" id="search" url="/admin/keyword/index">搜索</button>
                      </span>
                    </div>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-striped b-t b-light" id="export-form">
                    <thead>
                    <tr>
                        <th style="width:20px;"><label class="checkbox m-n i-checks"><input type="checkbox"><i></i></label>
                        </th>
                        <th>话题标题</th>
                        <th>内容	</th>
                        <th>关注</th>
                        <th>合并</th>
                        <th>状态	</th>
                        <th>最后编辑用户</th>
                        <th>添加时间</th>
                        <th style="width:130px;">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for item in list.data %}
                    <tr>
                        <td><label class="checkbox m-n i-checks"><input type="checkbox" class="ids" value="{{item.id}}"
                                                                        name="ids" ><i></i></label>
                        </td>
                        <td>{{ item.keyname }}</td>
                        <td>{{ item.videonum }}</td>
                        <td>{{ item.focus_count}}</td>
                        <td>{%if item.merged_id==0%}否{%else%}是{%endif%}</td>
                        <td> <a href="/admin/keyword/lock/?ids={{item.id}}&lock={{1-item.lock}}" class="active ajax-get" data-toggle="class">
                            <i class="fa fa-lock text-danger {%if item.lock %}text-active{%else%}text{%endif%}"></i>
                            <i class="fa fa-unlock text-success {%if item.lock %}text{%else%}text-active{%endif%}"></i>
                        </a></td>
                        <td>{{item.lastuser|get_nickname}}</td>
                        <td>
                            {{item.add_time|moment('YYYY-MM-DD HH:mm:ss')}}
                        </td>
                        <td>
                            <a href="/admin/keyword/edit/?id={{item.id}}" class="text-info">编辑</a>
                            <a href="/admin/keyword/del/?ids={{item.id}}" class="text-info ajax-get confirm" >删除</a>
                        </td>
                    </tr>
                    {% endfor %}

                    </tbody>
                </table>
            </div>
            <footer class="panel-footer">
                <div class="row">
                    <div class="col-md-3">
                        <div class="btn-group">
                            <a class="btn btn-sm btn-default todo" target-form="ids" href="#">
                                微信图文
                            </a>
                            <a class="btn btn-sm btn-default todo" target-form="ids" href="#">
                                高级图文
                            </a>
                            <a class="btn btn-sm btn-default todo" target-form="ids" href="#">
                                推送
                            </a>
                        </div>
                    </div>

                    <div class="col-md-9 text-right text-center-xs">
                        {{pagerData | safe}}
                    </div>
                </div>
            </footer>
        </section>
    </section>
</section>


{% endblock %}

{% block script %}
<script>
    //搜索功能
    $("#search").click(function(){
        var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
        window.location.href = url;
    });

    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });
</script>
{% endblock %}